#ifndef GROUPMEMBERMODEL_H
#define GROUPMEMBERMODEL_H

#include "../../global/xnamespace.h"
#include "ContactModel.h"

X_BEGIN_NAMESPACE

class GroupMemberModelPrivate : public QSharedData {
public:
    QString m_bareJid;
    QString m_name;
    QString m_photo;
    PhotoType m_photoType;
    AvailableStatus m_availableStatus;
};

/**
 * @brief 群成员模型。
 *
 * 群成员不一定是自己的好友。因此需要单独存储成员的信息，如：bareJid，昵称，姓名，头像等。
 *
 * 注意：目前群成员的信息均通过在线方式获取。
 */
class GroupMemberModel : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString bareJid READ bareJid NOTIFY jidChanged)
    Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
    Q_PROPERTY(QString photo READ photo WRITE setPhoto NOTIFY photoChanged)
    Q_PROPERTY(X::PhotoType photoType READ photoType WRITE setPhotoType NOTIFY photoTypeChanged)
    Q_PROPERTY(X::AvailableStatus availableStatus READ availableStatus WRITE setAvailableStatus NOTIFY availableStatusChanged)

signals:
    void jidChanged(QString bareJid);
    void nickNameChanged(QString nickName);
    void photoChanged(QString photo);
    void availableStatusChanged(X::AvailableStatus availableStatus);
    void photoTypeChanged(X::PhotoType photoType);

public:
    GroupMemberModel();
    GroupMemberModel(const QString bareJid);
    GroupMemberModel(const GroupMemberModel& src);
    GroupMemberModel &operator =(GroupMemberModel& rhs);

    QString bareJid() const;
    QString nickName() const;
    QString photo() const;
    PhotoType photoType() const;
    AvailableStatus availableStatus() const;

public:
    static const char *qmlName();

public slots:
    GroupMemberModel &setNickName(QString nickName);
    GroupMemberModel &setPhoto(QString photo);
    GroupMemberModel &setAvailableStatus(AvailableStatus status);
    GroupMemberModel &setPhotoType(X::PhotoType photoType);

private:
    bool isFriendWithMe() const;

private:
    QSharedDataPointer<GroupMemberModelPrivate> d;
};

X_END_NAMESPACE

#endif // GROUPMEMBERMODEL_H
